import {request} from "@/utils/service"
import {obj2param} from "@/utils/index";
import {getToken} from "@/utils/cache/cookies";

export const userReq = {
  baseUrl: '/user',
  userList(data) {
    return request({
      url: this.baseUrl + "/userList",
      method: "post",
      isSearchList: true,
      data
    })
  },
  addUser(data) {
    return request({
      url: this.baseUrl + "/addUser",
      method: "post",
      data
    })
  },
  getRoleList() {
    return request({
      url: this.baseUrl + "/getRoleList",
      method: "post",
    })
  },
  delUser(userId: any) {
    return request({
      url: this.baseUrl + "/delUser",
      method: "post",
      params:{
        userId
      }
    })
  },
  resetPassword(userId: any, value: undefined) {
    return request({
      url: this.baseUrl + "/resetPassword",
      method: "post",
      params:{
        username: userId,
        newPassword: value
      }
    })
  },
  resetInitPassword(value: undefined) {
    return request({
      url: this.baseUrl + "/resetInitPassword",
      method: "post",
      params:{
        newPassword: value
      }
    })
  },
  getUserById(userId: any) {
    return request({
      url: this.baseUrl + "/getUserById",
      method: "post",
      params:{
        userId
      }
    })
  },
  getAuthList() {
    return request({
      url: this.baseUrl + "/getAuthList",
      method: "post",
    })
  },
  updateUser(formData: {}) {
    return request({
      url: this.baseUrl + "/updateUser",
      method: "post",
      data: formData
    })
  }
}
